package br.edu.ufcg.lp2;


/**
 * This class represents a User characterized by a name
 * 
 * @author João Pedro Leôncio <joopeeds@gmail.com>
 * @author Franco Stefano <stefano.tejo@gmail.com>
 * @author Fellype Cavalcante <fellype.cavalcante@gmail.com>
 */

public class User {
	
	private String name;
	

	/**
	 * 
	 * @param name
	 * 		The name itself
	 * @throws Exception
	 * 		If the name are empty
	 */
	
	public User(String name) throws Exception{
		setName(name);
	}
	
	/**
	 **
	 * Changes the name 
	 * @param name
	 * 		The name itself
	 * @throws Exception
	 * 		If the name is an empty string
	 */


	public void setName(String name) throws Exception {
		if(name.trim().length() == 0) throw new Exception("Name cannot be empty");
		this.name = name;
	}

	/**
	 * Gets the name itself
	 * @return The name
	 */
	
	
	public String getName() {
		return name;
	}
	
	/**
	 * Checks whether a user equals another user (or object)
	 * A user equals another one, if the names do not differ
	 */

	@Override
	public boolean equals(Object obj) {
		if (getClass() != obj.getClass()) return false;
		return ((User) obj).getName().equals(getName());
	}
	
	
}
